import React, { PureComponent } from 'react'

export default class CounterClass extends PureComponent {
  constructor(props) {
    super(props)

    this.state = {
      count: 0,
      // info: {
      //   name: "yzh",
      //   age: 18
      // }
    }
  }

  render() {
    // console.log(this.state.info);
    return (
      <div>
        <h2>当前计数：{this.state.count}</h2>
        <button onClick={e => this.increment()}>+1</button>
        <button onClick={e => this.decrement()}>-1</button>
      </div>
    )
  }

  increment() {
    this.setState({
      count: this.state.count + 1,
      // info: {
      //   name: "ACE",
      //   age: 22
      // }
    })
  }

  decrement() {
    this.setState({
      count: this.state.count - 1
    })
  }
}
